#include <iostream>
#include <cmath>

using namespace std;

int issu(int num)
{   if( num <= 1 ) return 0;
    if (num == 2 || num == 3) return 1;
    if (num & 1)
    {
        for (int i = 2; i <= sqrt(num); i++)
        {
            if (num % i == 0) return 0;
        }
        return 1;
    }
    return 0;
}

int main(int argc, char const *argv[])
{
    int n, temp;
    scanf("%d", &n);
    while (n--)
    {
        scanf("%d", &temp);
        if(issu(temp)) printf("%d ",temp);
    }

    return 0;
}
